package com.gthncz;


import java.util.Scanner;

public class MeituanDemo1 {

    public static void  main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        String content = sc.next();
        // head part
        int sm = 0;
        while (sm < len && content.charAt(sm) != 'M') ++ sm;

        if (sm == len || sm != 0) {
            System.out.printf("");
            return;
        }

        int st = sm+1;
        while (st < len && content.charAt(st) != 'T') ++st;
        if (st == len) {
            System.out.printf("");
            return;
        }


        int et = len-1;
        if (content.charAt(et) != 'T') {
            System.out.printf("");
            return;
        }

        int em = et -1;
        while (em > st && content.charAt(em) != 'M') --em;
        if (em == st) {
            System.out.printf("");
            return;
        }

        System.out.printf(content.substring(st+1, em));
    }

}
